Dynamically redirecting a file descriptor

ABSTRACT

The method includes identifying a first executing process using a second executing process. The first executing process may include a file descriptor and the first executing process may be independent of the second executing process. The method includes disassociating the file descriptor from a first data stream using the second executing process without involvement of the first executing process. The method includes associating the file descriptor with a second data stream using the second executing process without involvement of the first executing process in response to disassociating the file descriptor from the first data stream.

STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH

This invention was made with Government support under HR0011-07-9-0002awarded by Defense Advanced Research Projects Agency (“DARPA”). TheGovernment has certain rights to this invention.

FIELD

The subject matter disclosed herein relates to file descriptors and moreparticularly relates to dynamically redirecting a file descriptor.

BACKGROUND Description of the Related Art

Processes typically use file descriptors to access data streams such asfiles, pipes, sockets, and the like. A process may write to or read froma data stream using a file descriptor referencing that data stream. Theassociation between the file descriptor and the data stream is oftenpersistent across the lifetime of the process. A process may also oftenhave one or more aliases (“dups”) of a data stream.

Once a process is executing, an administrator typically has no controlover the file descriptors, including the dups, of the process.Specifically, the administrator often has no way of directing the datawritten to one of the dups to go to a different file without shuttingdown the process and restarting it with the desired file descriptorpointing to a different data stream and, as a result, losing any statedata that the process has acquired, especially if the process has beenexecuting for a long period of time.

BRIEF SUMMARY

A method for dynamically redirecting a file descriptor is presented. Inone embodiment, the method includes identifying a first executingprocess using a second executing process. The first executing processincludes a file descriptor and the first executing process is typicallyindependent of the second executing process. In another embodiment, themethod includes disassociating the file descriptor from a first datastream using the second executing process without involvement of thefirst executing process. In another embodiment, the method includesassociating the file descriptor with a second data stream using thesecond executing process without involvement of the first executingprocess in response to disassociating the file descriptor from the firstdata stream.

An apparatus for dynamically redirecting a file descriptor is providedwith a plurality of modules configured to functionally execute the stepsdescribed above with regard to the presented method. These modules, inthe described embodiments, include an identification module, andisassociation module, and an association module.

In one embodiment, the identification module identifies a firstexecuting process in response to a second executing process. The firstexecuting process includes a first file descriptor. The first executingprocess is typically independent of the second executing process. Inanother embodiment, the disassociation module disassociates the filedescriptor from a first data stream in response to the second executingprocess without involvement of the first executing process. In anotherembodiment, the association module associates the file descriptor with asecond data stream in response to the second executing process withoutinvolvement of the first executing process in response to thedisassociation module disassociating the first executing process fromthe first file descriptor.

A system for dynamically redirecting a file descriptor is alsopresented. The system may be embodied by an operating system, aprocessor, and a memory storing modules for execution by the processor.The modules include an identification module, an disassociation module,and an association module. In one embodiment, the identification moduleidentifies a first executing process using a second executing process.The first executing process includes a first file descriptor. The firstexecuting process is typically independent of the second executingprocess. In another embodiment, the disassociation module disassociatesthe file descriptor from a first data stream using the second executingprocess without involvement of the first executing process. In anotherembodiment, the association module associates the file descriptor with asecond data stream using the second executing process withoutinvolvement of the first executing process in response to thedisassociation module disassociating the first executing process fromthe first file descriptor.

A computer program product comprising a computer readable storage mediumhaving computer readable program code for dynamically redirecting a filedescriptor is also presented. In one embodiment, the computer programproduct includes identifying a first executing process using a secondexecuting process. The first executing process includes a filedescriptor and the first executing process is independent of the secondexecuting process. In another embodiment, the computer program productincludes disassociating the file descriptor from a first data streamusing the second executing process without involvement of the firstexecuting process. In yet another embodiment, the computer programproduct includes associating the file descriptor with a second datastream using the second executing process without involvement of thefirst executing process in response to disassociating the filedescriptor from the first data stream.

Another method is presented. The method in the disclosed embodimentsincludes integrating a file descriptor redirection apparatus with anoperating system. The file descriptor redirection apparatus module, incertain embodiments, is capable of performing the steps of the methoddescribed above.

References throughout this specification to features, advantages, orsimilar language do not imply that all of the features and advantagesmay be realized in any single embodiment. Rather, language referring tothe features and advantages is understood to mean that a specificfeature, advantage, or characteristic is included in at least oneembodiment. Thus, discussion of the features and advantages, and similarlanguage, throughout this specification may, but do not necessarily,refer to the same embodiment.

Furthermore, the described features, advantages, and characteristics ofthe embodiments may be combined in any suitable manner. One skilled inthe relevant art will recognize that the embodiments may be practicedwithout one or more of the specific features or advantages of aparticular embodiment. In other instances, additional features andadvantages may be recognized in certain embodiments that may not bepresent in all embodiments.

BRIEF DESCRIPTION OF THE DRAWINGS

In order that the advantages of the embodiments of the invention will bereadily understood, a more particular description of the embodimentsbriefly described above will be rendered by reference to specificembodiments that are illustrated in the appended drawings. Understandingthat these drawings depict only some embodiments and are not thereforeto be considered to be limiting of scope, the embodiments will bedescribed and explained with additional specificity and detail throughthe use of the accompanying drawings, in which:

FIG. 1A is a schematic block diagram illustrating one embodiment of asystem for dynamically redirecting a file descriptor in accordance withthe present invention;

FIG. 1B is a schematic block diagram illustrating one embodiment of asystem for dynamically redirecting a file descriptor in accordance withthe present invention;

FIG. 2 is a schematic block diagram illustrating one embodiment of anapparatus for dynamically redirecting a file descriptor in accordancewith the present invention;

FIG. 3 is a schematic block diagram illustrating another embodiment ofan apparatus for dynamically redirecting a file descriptor in accordancewith the present invention;

FIG. 4A is a schematic block diagram illustrating one embodiment of afile descriptor table in accordance with the present invention;

FIG. 4B is a schematic block diagram illustrating one embodiment of afile descriptor table in accordance with the present invention;

FIG. 4C is a schematic block diagram illustrating one embodiment of afile descriptor table in accordance with the present invention;

FIG. 5 is a schematic flow chart diagram illustrating one embodiment ofa method for dynamically redirecting a file descriptor in accordancewith the present invention;

FIG. 6 is a schematic flow chart diagram illustrating another embodimentof a method for dynamically redirecting a file descriptor in accordancewith the present invention;

FIG. 7 is a schematic flow chart diagram illustrating another embodimentof a method for dynamically redirecting a file descriptor in accordancewith the present invention;

FIG. 8A is a schematic flow chart diagram illustrating one embodiment ofa method for integrating a file descriptor redirection apparatus with anoperating system in accordance with the present invention; and

FIG. 8B is a continuation of FIG. 8A illustrating one embodiment of themethod for integrating the file descriptor redirection apparatus withthe operating system in accordance with the present invention.

DETAILED DESCRIPTION

As will be appreciated by one skilled in the art, aspects of the presentinvention may be embodied as a system, method or computer programproduct. Accordingly, aspects of the present invention may take the formof an entirely hardware embodiment, an entirely software embodiment(including firmware, resident software, micro-code, etc.) or anembodiment combining software and hardware aspects that may allgenerally be referred to herein as a “circuit,” “module” or “system.”Furthermore, aspects of the present invention may take the form of acomputer program product embodied in one or more computer readablemedium(s) having computer readable program code embodied thereon.

Many of the functional units described in this specification have beenlabeled as modules, in order to more particularly emphasize theirimplementation independence. For example, a module may be implemented asa hardware circuit comprising custom VLSI circuits or gate arrays,off-the-shelf semiconductors such as logic chips, transistors, or otherdiscrete components. A module may also be implemented in programmablehardware devices such as field programmable gate arrays, programmablearray logic, programmable logic devices or the like.

Modules may also be implemented in software for execution by varioustypes of processors. An identified module of computer readable programcode may, for instance, comprise one or more physical or logical blocksof computer instructions which may, for instance, be organized as anobject, procedure, or function. Nevertheless, the executables of anidentified module need not be physically located together, but maycomprise disparate instructions stored in different locations which,when joined logically together, comprise the module and achieve thestated purpose for the module.

Indeed, a module of computer readable program code may be a singleinstruction, or many instructions, and may even be distributed overseveral different code segments, among different programs, and acrossseveral memory devices. Similarly, operational data may be identifiedand illustrated herein within modules, and may be embodied in anysuitable form and organized within any suitable type of data structure.The operational data may be collected as a single data set, or may bedistributed over different locations including over different storagedevices, and may exist, at least partially, merely as electronic signalson a system or network. Where a module or portions of a module areimplemented in software, the computer readable program code may bestored and/or propagated on in one or more computer readable medium(s).

The computer readable medium may be a tangible computer readable storagemedium storing the computer readable program code. The computer readablestorage medium may be, for example, but not limited to, an electronic,magnetic, optical, electromagnetic, infrared, holographic,micromechanical, or semiconductor system, apparatus, or device, or anysuitable combination of the foregoing.

More specific examples of the computer readable medium may include butare not limited to a portable computer diskette, a hard disk, a randomaccess memory (“RAM”), a read-only memory (“ROM”), an erasableprogrammable read-only memory (“EPROM” or “Flash memory”), a portablecompact disc read-only memory (“CD-ROM”), a digital versatile disc(“DVD”), an optical storage device, a magnetic storage device, aholographic storage medium, a micromechanical storage device, or anysuitable combination of the foregoing. In the context of this document,a computer readable storage medium may be any tangible medium that cancontain, and/or store computer readable program code for use by and/orin connection with an instruction execution system, apparatus, ordevice.

The computer readable medium may also be a computer readable signalmedium. A computer readable signal medium may include a propagated datasignal with computer readable program code embodied therein, forexample, in baseband or as part of a carrier wave. Such a propagatedsignal may take any of a variety of forms, including, but not limitedto, electrical, electro-magnetic, magnetic, optical, or any suitablecombination thereof. A computer readable signal medium may be anycomputer readable medium that is not a computer readable storage mediumand that can communicate, propagate, or transport computer readableprogram code for use by or in connection with an instruction executionsystem, apparatus, or device. Computer readable program code embodied ona computer readable signal medium may be transmitted using anyappropriate medium, including but not limited to wireless, wireline,optical fiber cable, Radio Frequency (“RF”), or the like, or anysuitable combination of the foregoing.

In one embodiment, the computer readable medium may comprise acombination of one or more computer readable storage mediums and one ormore computer readable signal mediums. For example, computer readableprogram code may be both propagated as an electro-magnetic signalthrough a fiber optic cable for execution by a processor and stored onRAM storage device for execution by the processor.

Computer readable program code for carrying out operations for aspectsof the present invention may be written in any combination of one ormore programming languages, including an object oriented programminglanguage such as Java, Smalltalk, C++ or the like and conventionalprocedural programming languages, such as the “C” programming languageor similar programming languages. The computer readable program code mayexecute entirely on the user's computer, partly on the user's computer,as a stand-alone software package, partly on the user's computer andpartly on a remote computer or entirely on the remote computer orserver. In the latter scenario, the remote computer may be connected tothe user's computer through any type of network, including a local areanetwork (“LAN”) or a wide area network (“WAN”), or the connection may bemade to an external computer (for example, through the Internet using anInternet Service Provider).

Reference throughout this specification to “one embodiment,” “anembodiment,” or similar language means that a particular feature,structure, or characteristic described in connection with the embodimentis included in at least one embodiment. Thus, appearances of the phrases“in one embodiment,” “in an embodiment,” and similar language throughoutthis specification may, but do not necessarily, all refer to the sameembodiment, but mean “one or more but not all embodiments” unlessexpressly specified otherwise. The terms “including,” “comprising,”“having,” and variations thereof mean “including but not limited to,”unless expressly specified otherwise. An enumerated listing of itemsdoes not imply that any or all of the items are mutually exclusive,unless expressly specified otherwise. The terms “a,” “an,” and “the”also refer to “one or more” unless expressly specified otherwise.

Furthermore, the described features, structures, or characteristics ofthe embodiments may be combined in any suitable manner. In the followingdescription, numerous specific details are provided, such as examples ofprogramming, software modules, user selections, network transactions,database queries, database structures, hardware modules, hardwarecircuits, hardware chips, etc., to provide a thorough understanding ofembodiments. One skilled in the relevant art will recognize, however,that embodiments may be practiced without one or more of the specificdetails, or with other methods, components, materials, and so forth. Inother instances, well-known structures, materials, or operations are notshown or described in detail to avoid obscuring aspects of anembodiment.

Aspects of the embodiments are described below with reference toschematic flowchart diagrams and/or schematic block diagrams of methods,apparatuses, systems, and computer program products according toembodiments of the invention. It will be understood that each block ofthe schematic flowchart diagrams and/or schematic block diagrams, andcombinations of blocks in the schematic flowchart diagrams and/orschematic block diagrams, can be implemented by computer readableprogram code. These computer readable program code may be provided to aprocessor of a general purpose computer, special purpose computer,sequencer, or other programmable data processing apparatus to produce amachine, such that the instructions, which execute via the processor ofthe computer or other programmable data processing apparatus, createmeans for implementing the functions/acts specified in the schematicflowchart diagrams and/or schematic block diagrams block or blocks.

The computer readable program code may also be stored in a computerreadable medium that can direct a computer, other programmable dataprocessing apparatus, or other devices to function in a particularmanner, such that the instructions stored in the computer readablemedium produce an article of manufacture including instructions whichimplement the function/act specified in the schematic flowchart diagramsand/or schematic block diagrams block or blocks.

The computer readable program code may also be loaded onto a computer,other programmable data processing apparatus, or other devices to causea series of operational steps to be performed on the computer, otherprogrammable apparatus or other devices to produce a computerimplemented process such that the program code which execute on thecomputer or other programmable apparatus provide processes forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks.

The schematic flowchart diagrams and/or schematic block diagrams in theFigures illustrate the architecture, functionality, and operation ofpossible implementations of apparatuses, systems, methods and computerprogram products according to various embodiments of the presentinvention. In this regard, each block in the schematic flowchartdiagrams and/or schematic block diagrams may represent a module,segment, or portion of code, which comprises one or more executableinstructions of the program code for implementing the specified logicalfunction(s).

It should also be noted that, in some alternative implementations, thefunctions noted in the block may occur out of the order noted in theFigures. For example, two blocks shown in succession may, in fact, beexecuted substantially concurrently, or the blocks may sometimes beexecuted in the reverse order, depending upon the functionalityinvolved. Other steps and methods may be conceived that are equivalentin function, logic, or effect to one or more blocks, or portionsthereof, of the illustrated Figures.

Although various arrow types and line types may be employed in theflowchart and/or block diagrams, they are understood not to limit thescope of the corresponding embodiments. Indeed, some arrows or otherconnectors may be used to indicate only the logical flow of the depictedembodiment. For instance, an arrow may indicate a waiting or monitoringperiod of unspecified duration between enumerated steps of the depictedembodiment. It will also be noted that each block of the block diagramsand/or flowchart diagrams, and combinations of blocks in the blockdiagrams and/or flowchart diagrams, can be implemented by specialpurpose hardware-based systems that perform the specified functions oracts, or combinations of special purpose hardware and computer readableprogram code.

FIG. 1A depicts one embodiment of a system 100 for dynamicallyredirecting a file descriptor in accordance with the present invention.In the depicted embodiment, system 100 includes a computing system 102with a processor 105, a memory 110, and storage 115. The computingsystem 102 is in communication with one or more clients 119 a, 119 b,119 c, through a network 117.

The memory 110 stores computer readable programs. The memory may beembodied by volatile memory such as dynamic random access memory(“DRAM”), static random access memory (“SRAM”), or other suitablevolatile memory. The processor 105 executes the computer readableprograms as is well known to those skilled in the art. The computerreadable programs may be tangibly stored in storage 115. The storage 115may include a Solid State Drive (“SSD”), a hard disk drive (“HDD”), anoptical storage device, a holographic storage device, a micromechanicalstorage device, or other non-volatile data storage device. The computingsystem 102 may be embodied by a server computer, a desktop computer, alaptop computer, a tablet computer, a mobile device, a set top box, oranother device that includes a processor and a memory. The computerreadable programs may include an operating system to execute on thecomputing system 102 and to manage software and hardware resources ofthe computing system 102. The operating system may comprise a Linuxoperating system, a Unix operating system, an operating system accordingto Portable Operating System Interface for Unix (“POSIX”), or any othersuitable operating system.

The network 117 may comprise a communications network such as theInternet, a Local Area Network (“LAN”), a Wireless LAN (“WLAN”),multiple LANs communicating over the Internet, or any other similarcommunications network. Each client 119 a, 119 b, 119 c may communicatewith the computing system 102 through the network 117. In oneembodiment, a client 119 a may be embodied as a desktop computer, aportable computer, a server, a mainframe computer, a handheld computingdevice, a touch device, a PDA, a tablet computer, an e-Book reader, amobile phone, a Smartphone, and the like. In one embodiment, the client210 a may also include and/or is embodied as a software application.

FIG. 1B depicts one embodiment of a system 120 for dynamicallyredirecting a file descriptor. Specifically, FIG. 1B depicts softwarelayers that may execute on the computing system 102 of FIG. 1A and maycomprise at least a portion of the operating system of the computingsystem 102. FIG. 1B includes application software 130 executing in userspace 125 of the computing system 102. User space 125 is segregated 142from kernel space 145. FIG. 1B also includes an operating system kernel150 executing in kernel space 145.

The application software 130 includes applications, utilities, and/orprocesses that operate in user space 125. As is known in the art,software code in the user space 125 is typically non-kernel code inwhich applications and utilities operate with controlled access tocomputer system resources. Processes running in user space 125 typicallycannot access the virtual memory of other processes directly. A processis a run-time instance of a computer readable program, executing on theoperating system of the computing system 102. Each process may includeits own resources, such as executable computer code, virtual memory, andoperating system resources described below. The application software 130includes a first process 135 and a second process 140. The first process135 and the second process 140 may be currently executing and may beindependent of one another (e.g. the second process 140 is not a childor parent of the first process 135). In one embodiment, the firstprocess 135 and/or the second process 140 is a system utility integratedwith and/or associated with the operating system. Furthermore, the firstprocess 135 and/or the second process 140 may be associated with acommand (e.g. an operating system utility such as an ln command) and/oruser space application.

As is known in the art, the kernel 150 is typically the primarycomponent of the operating system 100, providing communication betweenprocesses and the hardware of the computing system 102. Software codeexecuting in kernel space 145 has full access to system resources andruns the operating system kernel 150 and certain device drivers. Kernelspace memory is typically protected from applications running in userspace 125. In the depicted embodiment, the kernel 150 includes a systemcall interface 155 and a proc file system 160.

In the depicted embodiment, the system call interface 155 provides alibrary and/or application programming interface (“API”) to processes inuser space 125 to allow them to request services from the kernel 150through the use of a system call. The proc file system 160 typicallypresents information about processes in a file-like structure. As statedabove, the kernel 150 provides each process 135, 140 with kernelresources including file descriptors and a file descriptor table—akernel resident data structure—for each process 135, 140. A filedescriptor is an index to an entry in the file descriptor table. Thefile descriptor specifies one or more data streams associated with aprocess 135.

Each data stream may be a source for the process 140 to receive input ora destination for the process 135 to direct output. Data streams mayinclude files, directories, sockets, pipes, keyboard input, monitoroutput, and the like. A particular file descriptor may reference aparticular data stream and the file descriptor table translates theindex number of the particular file descriptor to the particular datastream (e.g. an open file). In one embodiment, each entry in the filedescriptor table has a pointer, or link, to a file object that includesinformation the kernel uses to access the data stream associated withthe file object (open mode, file offset, and the like). In oneembodiment, each entry in the file descriptor table has a pointer, orlink, to an entry in a system file table that includes entries foravailable data streams (e.g. open files).

In one embodiment, a file descriptor is an integer. Furthermore, certainoperating systems include three standard file descriptors for eachprocess: “0” for standard input (“stdin”), “1” for standard output(“stdout”), and “2” for standard error (“stderr”). For example, thefirst process 135 may have stdout referencing file “example1” and stderrreferencing file “example2.”

In conventional operating systems, the association between the filedescriptor and the data stream is often persistent across the lifetimeof the process 135. Once a process 135 is executing, an administratortypically has no control over the file descriptors of the process 135.Specifically, in conventional operating systems, the administrator oftenhas no way of directing the data for a data stream of a particular filedescriptor to go to a different data stream without shutting down theprocess 135 and restarting it with the desired file descriptor pointingto the different data stream.

Therefore, in one embodiment of the invention described herein, theoperating system includes a file descriptor redirection apparatus 165that dynamically redirects a file descriptor of a first process 135without involvement of the first process 135 and without shutting downthe first process 135. Specifically, the file descriptor redirectionapparatus 165 uses, is activated by, acts in behalf of, and/or acts inresponse to, a second process 140 independent from the first process135. The file descriptor redirection apparatus 165 may identify thefirst process 135 and may disassociate a file descriptor of the firstprocess 135 from a first data stream and associate the file descriptorwith a second data stream.

In one embodiment, the second process 140 is a conventional user spaceutility, such as an ln command utility for managing file links, whichcalls a conventional system call associated with the utility. The filedescriptor redirection apparatus 165 may detect that the user intends toredirect a file descriptor by, for example, detecting a predeterminedparameter and/or a file descriptor indicator instead of a file indicatorpassed with the ln command, and redirect the file descriptor in responseto detecting the predetermined parameter/file descriptor indicator. Byusing a conventional user space utility, but performing redirection ifthe user space utility specifies certain parameters, the file descriptorredirection apparatus 165 may provide users with a familiar interfaceand reduce modifications to user space 125 code.

In one embodiment, the file descriptor redirection apparatus 165provides a specialized system call to redirect a file descriptor. Inthis embodiment, the second process 140 may include a user space utilitythat makes the system call, passing in identifiers for the desiredprocess 135, the file descriptor to redirect of the desired process 135,and the new data stream to which the file descriptor is to beredirected.

For example, once a first process 135 is executing, the user mayencounter a particular error condition and wish to redirect stderr to aseparate file. Using the file descriptor redirection apparatus 165, theuser may redirect stderr without shutting down the first process 135 andlosing valuable state data and possibly losing the ability to replicatethe error condition.

In the depicted embodiment, the file descriptor redirection apparatus165 executes in kernel space 145. The file descriptor redirectionapparatus 165 may be in communication with, integrated with, and/orassociated with the operating system and/or the operating system kernel150. In another embodiment, a portion of the file descriptor redirectionapparatus 165 may also execute in user space 125 as, for example, autility (e.g. the second process 140).

FIG. 2 depicts one embodiment of an apparatus 165 for dynamicallyredirecting a file descriptor. The apparatus 165 is one embodiment ofthe file descriptor redirection apparatus 165 of FIG. 1B and includesone or more of an identification module 205, an disassociation module210 and an association module 215. In one embodiment, one or more of theidentification module 205, the disassociation module 210, and theassociation module 215 execute in kernel space 145 as depicted in FIG.1B showing the file descriptor redirection apparatus 165 residing inkernel space. In one embodiment, one or more of the identificationmodule 205, the disassociation module 210, and the association module215 execute in user space 125 and may, for example comprise at least aportion of the second executing process 140.

The identification module 205, in one embodiment, identifies a firstexecuting process 135 in which a user, application, or utility selectsfor file descriptor redirection. The identification module 205 mayidentify the first executing process 135 using a second executingprocess 140. For example, the user, application, or utility may pass inparameters, through the second executing process 140, specifying whichprocess for redirection. The identification module using the secondexecuting process 140 may also include the identification module 205acting in response to the second executing process 140 (e.g. the secondexecuting process 140 made a system call activating the identificationmodule 205), the identification module 205 acting by way of the secondexecuting process 140, the identification module 205 acting in behalf ofthe second executing process 140 and/or the like. In one embodiment, theidentification module 205 comprises kernel code executing for the secondexecuting process 140. The first executing process 135 includes at leastone file descriptor. Furthermore, the first executing process 135 may beindependent of the second executing process 140.

The identification module 205 may identify the first executing process135 by referencing a process identifier from the second executingprocess 140. For example, a user, application, or utility may include aprocess identifier as a command line parameter when running the secondprocess 140. The identification module 205 may then pass the processidentifier to the disassociation module 210 and/or reference applicablekernel data structures associated with the first executing process 135.

In one embodiment, as mentioned above, the second executing process 140is a user space 125 utility for managing file links. In a furtherembodiment, the second executing process 140 comprises an ln utility. Inone embodiment, the identification module 205 acts in response to thesecond executing process 140 calling an ln command system call (e.g. asystem call typically invoked by the ln command) but specifying a filedescriptor identifier instead of a file as described below.

The disassociation module 210, in one embodiment, disassociates the filedescriptor from a first data stream using the second executing process140. The disassociation module 210 using the second executing process140 may include the disassociation module 210 disassociating the filedescriptor, in response to, by way of, and/or in behalf of the secondexecuting process 140. In one embodiment, the first executing process135 continues to execute during the disassociation module 210disassociating the file descriptor from the first data stream andassociating the file descriptor with the second data stream.Furthermore, in some embodiments, the disassociation module 210disassociates the file descriptor from the first data stream withoutinvolvement of the first executing process 135. In a further embodiment,the first executing process 135 does not execute an instruction (orcausing kernel code to execute an instruction) that results indisassociating the file descriptor from the first data stream while thedisassociation module 210 disassociates the file descriptor.

In some embodiments, the disassociation module 210 disassociates thefile descriptor from the first data stream by removing a link from thefile descriptor to the first data stream. FIG. 4A depicts an embodiment400 of a file descriptor table 405 of the first process 135. The filedescriptor table 405 includes a plurality of file descriptors 410 a-c,with an associated file pointer for each file descriptor 415 a-c. Eachfile pointer 415 a-c creates a link 420 to a data stream 425 (e.g. afile entry in a systems file table). Referring to FIG. 4B, thedisassociation module 210 may remove the link 420 (e.g. change thepointer) between a particular file pointer 415 b and a particular datastream 425 b.

Referring back to FIG. 2, in one embodiment, the disassociation module210 receives a system call from the second executing process 140 todisassociate the file descriptor from the first data stream andassociate the file descriptor with the second data stream. The systemcall, in certain embodiments, is a specialized system call configured tocause the disassociation module 210 to disassociate the file descriptorfrom the first data stream in response to the system call as describedbelow.

In one embodiment, the first data stream is associated with a firstoutput terminal and the second data stream is associated with a secondoutput terminal. The disassociation module 210 may discontinue output ofthe first executing process 135 from the first output terminal inresponse to disassociating the file descriptor from the first datastream.

The association module 215, in one embodiment, associates the filedescriptor with a second data stream using the second executing process140. Similar to the disassociation module 210, the association module215 using the second executing process 140 may include the associationmodule 215 associating the file descriptor in response to, by way of,and/or in behalf of the second executing process 140. The associationmodule 215 may associate the file descriptor with the second data streamin response to and/or subsequent to the disassociation module 210disassociating the first executing process 135 from the first filedescriptor.

In one embodiment, the association module 215 associates the filedescriptor with the second data stream without involvement of the firstexecuting process 135. In a further embodiment, the first executingprocess 135 does not execute an instruction that results in associatingthe file descriptor with the second data stream. The first executingprocess 135 may continue executing during the association module 215associating the file descriptor with the second data stream.

In one embodiment, associating the file descriptor with the second datastream includes adding a link from the file descriptor to the seconddata stream. Referring also to FIG. 4C, the association module 215 maycreate a link 445 from the file pointer 415 b for the file descriptor tothe second data stream 425 a. In one embodiment, the association module215 may associate the file descriptor with a file path. In oneembodiment, the association module 215 may associate the file descriptorwith a data stream referenced by a file descriptor of the secondexecuting process 140.

In one embodiment, as stated above, the first data stream is associatedwith a first output terminal and the second data stream is associatedwith a second output terminal. The association module 215 may beginoutput of the first executing process 135 to the second output terminalin response to associating the file descriptor with the second datastream.

In one embodiment, the disassociation module 210 disassociates the filedescriptor from the first data stream and/or the association module 215associates the file descriptor with the second data stream using theproc file system 160. As known in the art, the proc file system 160presents information about processes in a file-like structure, includingproviding references to file descriptors of particular processes. Forexample, if an application with process id 75, has file descriptor 1pointing to file /tmp/foo.log, in Linux, this information may beretrieved by entering:

$ readlink /proc/75/fd/1

which would display:

/tmp/foo.log

(e.g. the file descriptor /proc/75/fd/1 is linked to /tmp/foo.log).

FIG. 3 depicts another embodiment of the file descriptor redirectionapparatus 165. In the depicted embodiment, the file descriptorredirection apparatus 165 includes the identification module 205, thedisassociation module 210, and the association module 215, which aresubstantially similar to those described in relation to FIG. 2. In theembodiment, the file descriptor redirection apparatus 165 furtherincludes one or more of a process module 300 a suspension mode module305, a receiving module 310, a detection module 315, and a triggeringmodule 320, which are described below. In one embodiment, one or more ofthe modules of the file descriptor redirection apparatus 165 execute inkernel space 145 as depicted in FIG. 1B showing the file descriptorredirection apparatus 165 residing in kernel space. In one embodiment,one or more of the modules execute in user space 125 and may, forexample comprise at least a portion of the second executing process 140.

The process module 300, in one embodiment, executes a user space 125process. The user space process may be the second executing process 140described herein. The process module 300, one embodiment, includes, isintegrated with, and or is embodied as, is a user space 125 utility—suchas the ln utility—for managing file links.

In one embodiment, the process module 300 may request file descriptorredirection by referring to a file descriptor as a parameter for the lncommand. Conventional kernel code executed for the ln command wouldreturn an error in response to a user or application specifying a filedescriptor (e.g. putting a file descriptor indicator as a parameter forthe ln command) instead of a file. However, in one embodiment, thedisassociation module 210 and/or the association module 215 include atleast a portion of kernel code called by the ln command and/orassociated with the proc file system 160 that will determine that theprocess module 300 has specified a file descriptor (e.g. a user orapplication has initiated the ln command using a file descriptor as aparameter) and redirect the link of the file descriptor, as referencedin a file form with the proc file system 160, to the new data stream. Anon-limiting example of a possible ln command (e.g. embodied by theprocess module 300) usable by the disassociation module 210 andassociation module 215 may be:

In −sf [new target file]/proc/[process identifier]/fd/[fd to retarget]

where “new target file” is the data stream to which the file descriptoris to be redirected, “process identifier” identifies the first executingprocess 135 for redirection, and “fd to retarget” is the file descriptorfor which redirection is desired. For example, a user may wish toredirect a file descriptor for a particular file. The user may use thefamiliar interface of the conventional ln command, instead substitutingthe file descriptor that the user wants to redirect from as a parameterinstead of a file.

In one embodiment, instead of (or in addition to) using the conventionalln utility to allow a user or application to initiate file descriptorredirection, initiates a specialized system call (instead of the systemcall typically associated with the ln command), through the secondexecuting process 140, to disassociate the file descriptor from thefirst data stream and associate the file descriptor with the second datastream. The system call may include parameters specifying a processidentifier, a file descriptor identifier, and a data stream identifieror a second file descriptor identifier (the association module 215 mayassociate the process with the data stream of the second file descriptoridentifier. A non-limiting example of C code for the system call is:

[new fd]=open(“[new target file]”, O_RDWR); fstat([new fd], . . . );

retarget_fd([process identifier], [old fd], [new fd]);

where “new fd” refers to a identifier for a second file descriptorrepresenting the second data stream, which, when used right before theretarget operation with the “open( )” function and the “fstat( )”function, may open and verify the new file while minimizing raceconditions. The “new target file” designates the second data stream,“retarget_fd” is the system call, and “old fd” is the file descriptorwith the link to the first data stream. The process module 300 mayinitiate the specialized system call to trigger the disassociationmodule 210 and the association module 215 as described above.

In certain embodiments or with certain processes, the first executingprocess 135 may be put into a suspension mode prior to file descriptorredirection. For example, the first executing process may be put into asuspension mode to avoid certain race conditions. The suspension modemodule 305, in one embodiment, puts the first executing process 135 intoa suspension mode prior to the disassociation module 210 disassociatingthe file descriptor from the first data stream. The suspension modemodule 305 may put the first executing process 135 into a suspensionmode using, in behalf of, and/or in response to, the second executingprocess 140. The suspension mode module 305 may put the first executingprocess 135 into the suspension mode in response to a parameter passedfrom the second executing process 140, a default setting, or the like.For example, the user may wish to first suspend the first executingprocess 135 prior to redirection and notify the suspension mode module305 with a parameter input into the process module 300. The suspensionmode module 305, in one embodiment, further takes the first executingprocess 135 out of the suspension mode using the second executingprocess 140 subsequent to the association module 215 associating thefile descriptor with the second data stream. The suspension mode may bea quiesced state in which the first executing process 135 maintains itsstate data, its run-time variables and the like, but does not executeany further operations while in the suspension mode. Conversely, aprocess that is shut down would lose state data and run-time variables,forcing the user to possibly have to re-run the process for days orweeks to obtain the same state. Thus, an embodiment where the firstexecuting process is merely put in a suspension mode may be advantageousover the prior art method of shutting down the process.

The receiving module 310, in one embodiment, receives and/or referencesparameters that specify a process to redirect, a particular filedescriptor to redirect, and/or a data stream to redirect the particularfile descriptor to. These parameters may include a process identifier, afile descriptor identifier, and a data stream identifier. In oneembodiment, these identifiers may include parameters and arguments inputby a user or application into the process module 300 and/or the secondprocess 140. The process identifier identifies the first executingprocess 135 (e.g. a string identifier in file notation according to theproc file system 160). The file descriptor identifier identifies thefile descriptor (e.g. also a string identifier in file notationaccording to the proc file system 160). The data stream identifieridentifies the second data stream (e.g. a file path designating the newdata stream to redirect the file descriptor to). The receiving module310 may receive and/or reference the identifiers from parameters of thesecond executing process 140 and/or variables in a system call. Thereceiving module 310 may also receive any other parameters such as asuspension mode parameter specifying whether to put the first executingprocess 135 into the suspension mode.

The detection module 315 allows the file descriptor redirectionapparatus 165 to perform file descriptor redirection in response toreceiving a command with an existing utility such as the ln utilityinstead of the operating system returning an error when the user orapplication uses a file descriptor as a parameter in the utility.Specifically, the detection module 315 detects the utility (e.g. thesecond executing process 140 embodied by the process module 300)specifying a file descriptor instead of a file in its parameters.Instead of the operating system returning an error as in conventionaloperating systems, the detection module 315 detects the file descriptorparameter and signals the disassociation module 210. In one embodiment,the disassociation module 210 disassociating the file descriptor fromthe first data stream and the association module 215 associating thefile descriptor with a second data stream occur in response to thedetection module 315 detecting the second executing process 140 specifythe file descriptor instead of the file. As stated above, the use mayuse a pre-existing utility, the ln command, specifying a file descriptorinstead of a file.

The triggering module 320 automatically triggers file descriptorredirection. Specifically, in one embodiment, the triggering module 320triggers disassociating the file descriptor from the first data streamand associating the file descriptor with a second data stream inresponse to predetermined criteria. The predetermined criteria mayinclude storage space reaching a threshold and/or an error condition.For example, a user may wish to have error messages directed to a firstfile unless the amount of error messages reaches a predeterminedthreshold, in which case the user may wish to redirect the errormessages to a second file. The user may also wish to redirect outputfrom the first executing process 135 from a disk nearing its capacity toanother disk. In one embodiment, the triggering module 320 is a userspace 125 utility that initiates file descriptor redirection. In afurther embodiment, the triggering module 320 comprises at least aportion of the second process 140 and/or initiates the process module300 in response to detecting the predetermined criteria.

FIG. 5 depicts one embodiment of a method 500 for dynamicallyredirecting a file descriptor. The method 500 begins and theidentification module 205 identifies 505 a first executing process 135using a second executing process 140. The first executing process 135includes a first file descriptor and the first executing process 135 istypically independent of the second executing process 140. Next, thedisassociation module 210 disassociates 510 the file descriptor from afirst data stream using the second executing process 140 withoutinvolvement of the first executing process 135. Then, the associationmodule 215 associates 515 the file descriptor with a second data streamusing the second executing process 140 without involvement of the firstexecuting process 135. In one embodiment, disassociating the filedescriptor from the first data stream and associating the filedescriptor with the second data stream includes changing a link from thefile descriptor to the first data stream to the file descriptor and thesecond data stream. Then, the method 500 ends.

FIG. 6 depicts one embodiment of another method 600 for dynamicallyredirecting a file descriptor. The method 600 begins and the processmodule 300 executes 605 a second process 140 initiated by a user orapplication. For example, the user may wish to redirect output of aparticular process because the user's disk is nearing capacity. Thesecond process 140 may include parameters specifying an identity of thefirst process 135, the desired file descriptor, and the data stream towhich the file descriptor will be redirected. In one embodiment, thesecond process 140 is a pre-existing utility such as the ln command. Theprocess module 300 then makes 610 a system call to the operating systemkernel 150. The system call may be a standard system call typicallyassociated with the ln command. The receiving module 310 receives 615the system call and/or notification or instructions from the system calland a process identifier, a file descriptor identifier, and a datastream identifier. If the detection module 315 determines 620 that thesecond process 140 is specifying a particular file descriptor instead ofa file in its parameters, instead of returning an error, theidentification module 205 identifies 625 a first executing process 135specified from the process identifier (e.g. passed in by the user orapplication as a parameter). The suspension mode module 305 determines630 whether to put the first executing process 135 into a suspensionmode (e.g. the second process 140 has specified a suspension modethrough a parameter or the suspension mode is a default setting for eachprocess or for certain processes). For example, the suspension modemodule 305 may be preconfigured to place certain processes, such asvital system processes, into a suspension mode before redirection. Ifthe suspension mode module 305 determines 630 that the first executingprocess 135 is to be put into the suspension mode, the suspension modemodule 305 puts 630 the first executing process 135 into the suspensionmode and the method 600 moves to step 640. Alternatively, the method 600moves directly to step 640.

Next, the disassociation module 210 disassociates 640 the filedescriptor from a first data stream. Then, the association module 215associates 645 the file descriptor with a second data stream. If thefirst process 135 is not in the suspension mode, the method 600 ends.Alternatively, the suspension mode module 305 takes 655 the firstprocess 135 out of suspension mode. Then, the method 600 ends. In someembodiments, the first data stream is associated with a first outputterminal and the second data stream is associated with a second outputterminal. In this embodiment, disassociating the file descriptor fromthe first data stream and associating the file descriptor with thesecond data stream switches output of the first executing process 135from the first output terminal to the second output terminal.

FIG. 7 depicts one embodiment of another method 700 for dynamicallyredirecting a file descriptor. The method 700 begins and the processmodule 300 executes 705 a second process 140 initiated by a user orapplication. For example, the user may wish to redirect output of aparticular process because the wishes to switch terminals. In oneembodiment, the process module 300 is configured to make a specializedsystem call to redirect a file descriptor. The process module 300 thenmakes 710 the system call to the operating system kernel. The receivingmodule 310 receives 715 the system call and/or notification of thesystem call and a process identifier, a file descriptor identifier, anda data stream identifier (e.g. parameters input from the user orapplication into the process module 300). The suspension mode module 305determines whether 725 to put the first executing process 135 into asuspension mode (e.g. the second process 140 has specified a suspensionmode through a parameter or the suspension mode is a default setting).If the suspension mode module 305 determines 725 that the firstexecuting process 135 is to be put into the suspension mode, thesuspension mode module 305 puts 730 the first executing process 135 intothe suspension mode and the method 700 moves to step 735. Alternatively,the method 700 moves directly to step 735.

Next, the disassociation module 210 disassociates 735 the filedescriptor from a first data stream. Then, the association module 215associates 740 the file descriptor with a second data stream. If thefirst process 135 is not in the suspension mode, the method 700 ends.Alternatively, the suspension mode module 305 takes 750 the firstprocess 135 out of suspension mode. Then, the method 700 ends.

FIGS. 8A and 8B depict one embodiment of a method 800 for integrating afile descriptor redirection apparatus 165 with an operating system. Thefile descriptor redirection apparatus 165 may comprise one or moreprocess software programs. In one embodiment, the process software whichincludes the file descriptor redirection apparatus 165 is integratedinto a client, server and network environment by providing for theprocess software to coexist with applications, operating systems andnetwork operating systems software and then installing the processsoftware on the clients and servers in the environment where the processsoftware will function.

A service provider, a network administrator, a user, or the like, mayidentify any software on the clients and servers including the networkoperating system where the process software will be deployed that arerequired by the process software or that work in conjunction with theprocess software. This may include the network operating system that issoftware that enhances a basic operating system by adding networkingfeatures.

Next, the software applications and version numbers may be identifiedand compared to the list of software applications and version numbersthat have been tested to work with the process software. Those softwareapplications that are missing or that do not match the correct versionmay be upgraded with the correct version numbers. Program instructionsthat pass parameters from the process software to the softwareapplications may be checked to ensure the parameter lists match theparameter lists required by the process software. Conversely, parameterspassed by the software applications to the process software may bechecked to ensure the parameters match the parameters required by theprocess software. The client and server operating systems including thenetwork operating systems will be identified and compared to the list ofoperating systems, version numbers and network software that have beentested to work with the process software. Those operating systems,version numbers and network software that do not match the list oftested operating systems and version numbers may be upgraded on theclients and servers to the required level. After ensuring that thesoftware, where the process software is to be deployed, is at thecorrect version level that has been tested to work with the processsoftware, the integration is completed by installing the processsoftware on the clients and servers.

The method 800 begins with determining 805 if there are any of theprocess software programs that will execute on a server or servers. Ifthis is not the case, then integration proceeds to 835. If this is thecase, then the server addresses are identified 810. The servers arechecked 815 to see if they contain software that includes the operatingsystem (“OS”), applications, and network operating systems (“NOS”),together with their version numbers that have been tested with theprocess software. The servers may also be checked 815 to determine ifthere is any missing software that is required by the process software.

A determination 820 is made if the version numbers match the versionnumbers of OS, applications and NOS that have been tested with theprocess software. If all of the versions match and there is no missingrequired software the integration continues in 835. If one or more ofthe version numbers do not match, then the unmatched versions areupdated 825 on the server or servers with the correct versions.Additionally if there is missing required software, then it is updated825 on the server or servers. The server integration is completed 830 byinstalling the process software. Step 835 which follows 805, 820, or 830determines 835 if there are any programs of the process software thatwill execute on the clients. If no process software programs execute onthe clients, the method 800 ends. If this not the case, then the clientaddresses are identified 840.

The clients are checked 845 to see if they contain software thatincludes the operating system (“OS”), applications, and networkoperating systems (“NOS”), together with their version numbers that havebeen tested with the process software. The clients may also be checked845 to determine if there is any missing software that is required bythe process software.

Referring to FIG. 8B, a determination is made 845 whether the versionnumbers match the version numbers of OS, applications and NOS that havebeen tested with the process software. If all of the versions match andthere is no missing required software, then, referring back to FIG. 8A,the method 800 ends.

Alternatively, if one or more of the version numbers do not match, thenthe unmatched versions are updated 850 on the clients with the correctversions. In addition, if there is missing required software then it isupdated 850 on the clients. The client integration is completed 855 byinstalling the process software on the clients, then, referring back toFIG. 8A, the method 800 ends.

The embodiments may be practiced in other specific forms. The describedembodiments are to be considered in all respects only as illustrativeand not restrictive. The scope of the invention is, therefore, indicatedby the appended claims rather than by the foregoing description. Allchanges which come within the meaning and range of equivalency of theclaims are to be embraced within their scope.

1. A method comprising: identifying a first executing process using asecond executing process, the first executing process comprising a filedescriptor, the first executing process independent of the secondexecuting process; disassociating the file descriptor from a first datastream using the second executing process without involvement of thefirst executing process; and associating the file descriptor with asecond data stream using the second executing process withoutinvolvement of the first executing process in response to disassociatingthe file descriptor from the first data stream.
 2. The method of claim1, wherein the file descriptor comprises an index to an entry in a filedescriptor table for the first executing process.
 3. The method of claim2, wherein the file descriptor specifies one of a source for the firstexecuting process to receive input and a destination for the firstexecuting process to direct output.
 4. The method of claim 1, whereindisassociating the file descriptor from the first data stream furthercomprises disassociating the file descriptor from the first data streamusing the second executing process without the first executing processexecuting an instruction that results in disassociating the filedescriptor from the first data stream and wherein associating the filedescriptor with the second data stream further comprises associating thefile descriptor with the second data stream using the second executingprocess without the first executing process executing an instructionthat results in associating the file descriptor with the second datastream.
 5. The method of claim 1, wherein the first executing processcontinues to execute during disassociating the file descriptor from thefirst data stream and associating the file descriptor with the seconddata stream.
 6. The method of claim 1, further comprising putting thefirst executing process into a suspension mode using the secondexecuting process prior to disassociating the file descriptor from thefirst data stream.
 7. The method of claim 6, further comprising takingthe first executing process out of the suspension mode using the secondexecuting process subsequent to associating the file descriptor with thesecond data stream.
 8. The method of claim 1, wherein disassociating thefile descriptor from the first data stream and associating the filedescriptor with the second data stream further comprises changing a linkfrom the file descriptor to the first data stream to the file descriptorand the second data stream, the file descriptor referencing a filedescriptor table for the first executing process.
 9. The method of claim1, further comprising receiving a process identifier, a file descriptoridentifier, and a data stream identifier, the process identifieridentifying the first executing process, the file descriptor identifieridentifying the file descriptor, and the data stream identifieridentifying the second data stream.
 10. The method of claim 1, whereinthe second executing process comprises a user space utility for managingfile links, the method further comprising detecting the second executingprocess specifying a particular file descriptor instead of a file,wherein disassociating the file descriptor from the first data streamand associating the file descriptor with a second data stream occur inresponse to detecting the second executing process specify theparticular file descriptor instead of the file.
 11. The method of claim10, wherein the second executing process comprises an In utility. 12.The method of claim 1, wherein the second executing process initiates asystem call to disassociate the file descriptor from the first datastream and associate the file descriptor with the second data stream,the method further comprising receiving the system call, whereindisassociating the file descriptor from the first data stream andassociating the file descriptor with the second data stream occur inresponse to receiving the system call.
 13. The method of claim 1,wherein the first data stream is associated with a first output terminaland the second data stream is associated with a second output terminal,the method further comprising switching output of the first executingprocess from the first output terminal to the second output terminal inresponse to disassociating the file descriptor from the first datastream and associating the file descriptor with a second data stream.14. The method of claim 1, further comprising triggering disassociatingthe file descriptor from the first data stream and associating the filedescriptor with a second data stream in response to one of storage spacereaching a threshold; and an error condition. 15-22. (canceled)
 23. Acomputer program product comprising a computer readable storage mediumhaving computer readable program code embodied therewith, the computerreadable program code for: identifying a first executing process using asecond executing process, the first executing process comprising a filedescriptor, the first executing process independent of the secondexecuting process; disassociating the file descriptor from a first datastream using the second executing process without involvement of thefirst executing process; and associating the file descriptor with asecond data stream using the second executing process withoutinvolvement of the first executing process in response to disassociatingthe file descriptor from the first data stream.
 24. The computer programproduct of claim 23, wherein the file descriptor comprises an index toan entry in a file descriptor table for the first executing process,wherein the file descriptor specifies one of a source for the firstexecuting process to receive input and a destination for the firstexecuting process to direct output.
 25. A method comprising: integratinga file descriptor redirection apparatus with an operating system, thefile descriptor redirection apparatus capable of, identifying a firstexecuting process using a second executing process, the first executingprocess comprising a file descriptor, the first executing processindependent of the second executing process; disassociating the filedescriptor from a first data stream using the second executing processwithout involvement of the first executing process; and associating thefile descriptor with a second data stream using the second executingprocess without involvement of the first executing process in responseto disassociating the file descriptor from the first data stream.